<template>
  <div class="goods" @click="handleLinkDetail(goodsInfo.iid, goodsInfo.id)">
    <img v-lazy="goodsInfo.show.img" class="image" />
    <div class="title">
      {{ goodsInfo.title }}
    </div>
    <div class="description">
      <span class="price">{{ goodsInfo.price | priceFilter }}</span>
      <span>
        <i class="iconfont icon-shoucang1" style="font-size: 12px"></i>
        {{ goodsInfo.cfav }}
      </span>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    goodsInfo: Object
  },
  filters: {
    priceFilter(price) {
      return '￥ ' + price.toFixed(2)
    }
  },
  methods: {
    handleLinkDetail(iid, id) {
      this.$router.push(`/detail/${iid}/${id}`)
    }
  }
}
</script>

<style lang="less" scoped>
.goods {
  background: white;
  box-sizing: border-box;
  width: 100%;
  padding: 15px 10px 0 10px;
  font-size: 12px;
  .image {
    width: 98%;
    border-radius: 5px;
  }
  .title {
    width: 42vw;
    text-overflow: ellipsis;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .description {
    text-align: center;
    line-height: 35px;
    .price {
      color: red;
      margin-right: 10px;
    }
  }
}
</style>
